////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   CODE
// AUTHOR           :   Saint Peng
// DATE CREATE      :   2006/01/05
// DESCRIPTION      :   a MAINTENANCE ACTION file for the function, CODE
//                  :
//                  :
//                  :
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/01/05   Saint Peng      1.0                 source is generated.
//
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.setup.catalogOption.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.erp.app.common.ProjectConstants;
import com.erp.app.setup.catalogOption.pk.CatalogOptionHdrPk;
import com.erp.app.setup.catalogOption.schema.CatalogOptionHdrSchema;
import com.erp.app.setup.catalogOption.vo.CatalogOptionHdrVo;
import com.erp.app.util.web.WebUtil;
import com.erp.framework.controller.action.SimpleMaintStyleAction;
import com.erp.framework.model.pk.SimpleBasePk;
import com.erp.framework.model.schema.TableSchema;
import com.erp.framework.util.CommonUtil;
import com.erp.framework.util.logger.Logger;
import com.erp.framework.util.user.User;

/**
* A <strong>Maintenance Action</strong> is an adapter between the contents of an incoming
* HTTP request and the corresponding business logic that should be executed to
* process this request.  The controller (ActionServlet) will select an
* appropriate Action for each request.
* The main purpose for this action class is to handle the user document maintenance events
* from the web browsers.
*
* @author          Saint Peng
* @version 1.0     2006/01/05
* @since           FrameWork 1.0
*
*/
public class CatalogOptionMaintenanceAction extends SimpleMaintStyleAction {

	////////////////////////////////////////////////////////////////////////////////
	// CONSTANTS DEFINITION
	////////////////////////////////////////////////////////////////////////////////

	//public static final String ACTION_DO_SOMETHING = "actionDoSomething";
	//public static final String STATUS_DO_SOMETHING = "statusDoSomething";

    public static final int TAB_IDX_DOC = -1;
	public static final int TAB_IDX_DTL = 0;

	public static final String ActionDelDetal = "delDetail";
	public static final String ACTION_CHANGE_FOLDER_DOC = ACTION_CHANGE_FOLDER + "Hdr";
	public static final String ACTION_CHANGE_FOLDER_DTL = ACTION_CHANGE_FOLDER + "Dtl";
	public static final String ACTION_EDIT_DESC = "taEditDtlRefDesc";
	public static final String STATUS_EDIT_REMARK = "sPSet";
	public static final String ACTION_EDIT_HDRDESC = "taEditHdrRefDesc";
    private static final String POPUP_FIELD_NAME_HDRDESC = "hdrDescription";
    private static final String POPUP_FIELD_HDRDESC = "hdrDescription";
    private static final String POPUP_FIELD_NAME_DTLDESC = "Description";
    private static final String POPUP_FIELD_DTLDESC = "dtlDescription";
    private static final String STATUS_IS_DELETE_CHECKED = "checked";

	////////////////////////////////////////////////////////////////////////////////
	// GLOBAL VARIABLES DEFINITION
	////////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////////
	// LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////

	public ActionForward handlePageEvent(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			if (!isHandled(request) && action.equalsIgnoreCase(ACTION_ADD_DTL)) {
				processActionAddDetail(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_DEL_DTL)) {
				processActionDelDetail(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_ADD_CHARGES)) {
				processActionAddCharges(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_CHANGE_CHARGES)) {
				processActionChangeCharges(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_DEL_CHARGES)) {
				processActionDelCharges(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_INCR_REVISION)) {
				processActionIncrRevision(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_PRINT_ENG)) {
				processActionPrintEnglish(mapping, formIn, request, response, errors);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_PRINT_CHN)) {
				processActionPrintChinese(mapping, formIn, request, response, errors);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ActionDelDetal)) {
				processActionDelDetail(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_EDIT_DESC)) {
				processActionEditRemark(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			} else if (!isHandled(request) && action.equalsIgnoreCase(ACTION_EDIT_HDRDESC )) {
				processActionEditRemark(mapping, formIn, request, response, errors);
				saveToken(request);
				setHandled(request);
			}
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processOtherStatus(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response,
		ActionErrors errors, String rb_status) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			if (rb_status.equalsIgnoreCase(STATUS_EDIT_REMARK)) {
				return processStatusEditRemark(mapping,  formIn,  request, response,  errors,  rb_status);
			}
		} catch (Exception e) {
			Logger.log(this, e);
		}

		return actionForward;
	}

	//uncomment the following code and implement the method if necessary

	protected ActionForward processActionEditRemark(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
//		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);
		String action = CommonUtil.nullToString(form.getPageEvent());

		try{
			if(action.equalsIgnoreCase(ACTION_EDIT_DESC)){
				session.removeAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);

				 String field = POPUP_FIELD_DTLDESC;
		         String fieldName = POPUP_FIELD_NAME_DTLDESC;
		         String fieldValue = "";
		         String eventSrc = form.getPageEventSrc();

		         TableSchema ts = form.getTs();
		         TableSchema[] childTsArray = form.getChildTs();
				 TableSchema dtlTs = childTsArray[CatalogOptionMaintenanceAction.TAB_IDX_DTL];

		         ArrayList rows = form.getMultiRows(0);
		         int idx = Integer.parseInt(eventSrc);
		         CatalogOptionDtlRow row = (CatalogOptionDtlRow) rows.get(idx);
		         fieldValue = row.getDtlRefDesc();


		         LinkedList keyList = new LinkedList();
		         keyList.add(dtlTs.getDisplayWebLabelByObjectId("LBL_SRCH_REF_MASTER_CODE"));
		         keyList.add(form.getRefMasterCode());
		         keyList.add(dtlTs.getDisplayWebLabelByObjectId("LBL_SRCH_REF_CODE"));
		         keyList.add(row.getRefCode());

		         HashMap params = new HashMap();
		         params.put(ProjectConstants.SESSION_SESSION_VALUE, getSessionSimpleMaintStatus());
		         params.put(ProjectConstants.SESSION_OPENER_PATH, getFunctionId());
		         params.put(ProjectConstants.SESSION_KEY_LIST, keyList);
		         params.put(ProjectConstants.SESSION_FIELD, field);
		         params.put(ProjectConstants.SESSION_EVENTSRC, eventSrc);
		         params.put(ProjectConstants.SESSION_EDIT_COLUMN_NAME, fieldName);
		         params.put(ProjectConstants.SESSION_EDIT_VALUE, fieldValue);

		         session.setAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS, params);
			}else if(action.equalsIgnoreCase(ACTION_EDIT_HDRDESC)){
				session.removeAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);


				String field = POPUP_FIELD_HDRDESC;
		         String fieldName = POPUP_FIELD_NAME_HDRDESC;
		         String fieldValue = form.getRefDesc();
		         String eventSrc = form.getPageEventSrc();
		         TableSchema ts = form.getTs();

		         LinkedList keyList = new LinkedList();
		         keyList.add(ts.getDisplayWebLabelByObjectId("LBL_SRCH_REF_MASTER_CODE"));
		         keyList.add(form.getRefMasterCode());

		         HashMap params = new HashMap();
		         params.put(ProjectConstants.SESSION_SESSION_VALUE, getSessionSimpleMaintStatus());
		         params.put(ProjectConstants.SESSION_OPENER_PATH, getFunctionId());
		         params.put(ProjectConstants.SESSION_KEY_LIST, keyList);
		         params.put(ProjectConstants.SESSION_FIELD, field);
		         params.put(ProjectConstants.SESSION_EVENTSRC, eventSrc);
		         params.put(ProjectConstants.SESSION_EDIT_COLUMN_NAME, fieldName);
		         params.put(ProjectConstants.SESSION_EDIT_VALUE, fieldValue);

		         session.setAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS, params);



			}
			System.out.println("You are in processActionDoSomething().");
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}


	//uncomment the following code and implement the method if necessary

	protected ActionForward processStatusEditRemark(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response,
		ActionErrors errors, String rb_status) {

		HttpSession session = request.getSession(false);
        ActionForward actionForward = new ActionForward(mapping.getInput());
		HashMap params = (HashMap) session.getAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);
        session.removeAttribute(ProjectConstants.SESSION_SELECT_REMARK_TEXT_PARAMETERS);
        String editValue = (String) params.get(ProjectConstants.SESSION_EDIT_VALUE);
        String editColumnName = (String) params.get(ProjectConstants.SESSION_EDIT_COLUMN_NAME);

        CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;

		try{
			if(editColumnName.equalsIgnoreCase(POPUP_FIELD_NAME_DTLDESC)){
				String field = (String) params.get(ProjectConstants.SESSION_FIELD);
                String eventSrc = (String) params.get(ProjectConstants.SESSION_EVENTSRC);
                ArrayList rows = form.getMultiRows(0);

                int idx = Integer.parseInt(eventSrc);
                CatalogOptionDtlRow row = (CatalogOptionDtlRow) rows.get(idx);
                row.setDtlRefDesc(editValue);
                return actionForward;




			}else if(editColumnName.equalsIgnoreCase(POPUP_FIELD_NAME_HDRDESC)){
				String field = (String) params.get(ProjectConstants.SESSION_FIELD);
                String eventSrc = (String) params.get(ProjectConstants.SESSION_EVENTSRC);
                form.setRefDesc(editValue);
                return actionForward;
			}
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}


	protected ActionForward processActionAddDetail(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{

			CatalogOptionDtlRow rowToAdd = new CatalogOptionDtlRow();
			form.setCurrIdx(0);
			rowToAdd.setCompanyCode(form.getCompanyCode());
			rowToAdd.setCompanyCode(form.getCompanyCode());
			rowToAdd.setIsDelete("");
			rowToAdd.setRefMasterCode(form.getRefMasterCode());
			rowToAdd.setRefCode("");
			rowToAdd.setModeCreate();
			rowToAdd.setDtlStatus(ProjectConstants.GENERIC_ACTIVE);
			form.addRow(rowToAdd);
   		    form.setSidx(Integer.parseInt(form.getLastPageSidx()));

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processActionDelDetail(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
			ArrayList rows = form.getMultiRows(TAB_IDX_DTL);
			int idx = Integer.parseInt(form.getPageEventSrc());
			CatalogOptionDtlRow rowToEdit = (CatalogOptionDtlRow) rows.get(idx);
			rowToEdit.setIsDelete(STATUS_IS_DELETE_CHECKED);
			form.setRow(idx, rowToEdit);

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processActionAddCharges(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		int originalCurrIndex = form.getCurrIdx();
		try {
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		} finally {
			form.setCurrIdx(originalCurrIndex);
		}

		return actionForward;
	}

	protected ActionForward processActionChangeCharges(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processActionDelCharges(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		int originalCurrIndex = form.getCurrIdx();
		try {
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	protected ActionForward processActionPrintEnglish(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return null;
	}

	protected ActionForward processActionPrintChinese(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return null;
	}

	protected ActionForward processActionIncrRevision(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try{
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}

		return actionForward;
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// OVERRIDES PARENT'S OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected void initAction(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initAction(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void initForm(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initForm(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void initPage(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		super.initPage(mapping, formIn, request, response, errors);

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeCreate(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			form.setCompanyCode(WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_CATALOG_OPTION));
			form.setTs(new CatalogOptionHdrSchema());
			form.setTsName("com.erp.app.setup.catalogOption.schema.CatalogOptionHdrSchema");

//			form.setDcInd(GENERIC_NO);
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeSave(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterSave(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeEdit(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterEdit(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeDelete(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterDelete(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void beforeRefresh(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	protected void afterRefresh(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	public String getSessionMaintStatus() {

		return getSessionSimpleMaintStatus();
	}

	public String getSessionMaintPk() {

		return getSessionSimpleMaintPk();
	}

	public String getStrutsId() {

		return getFunctionId();
	}

	protected String getSimpleSrchMenuId() {

		//TODO: Add the following line to ProjectMenuConstants.java
		//public static final String MOD_CATALOG_OPTION = "MOD_CATALOG_OPTION";
		return ProjectConstants.MOD_CATALOG_OPTION;
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// IMPLEMENTS PARENT'S ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected String getModuleName(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request,HttpServletResponse response) {

		//TODO: Add the following line to ProjectMenuConstants.java
		//public static final String MOD_CATALOG_OPTION = "MOD_CATALOG_OPTION";
		return ProjectConstants.MOD_CATALOG_OPTION;
	}

	protected String getFunctionId() {

		//struts-config xxxxx.do
		return "catalogOptionMaintenance.do";
	}

	protected Class getMasterFormClass() {

		//the corresponding form class
		return CatalogOptionMaintenanceForm.class;
	}

	protected Class getMasterVOClass() {

		//corresponding master vo class
		return CatalogOptionHdrVo.class;
	}

	protected String getMasterFormSessionName() {

		return "catalogOptionMaintenanceForm";
	}

	protected Class[] getChildRowClass() {

		Class[] childRowClass = new Class[1];

		childRowClass[0] = com.erp.app.setup.catalogOption.web.CatalogOptionDtlRow.class;

		return childRowClass;
	}

	protected String[] getFolderChildIdxMapping() {

		String[] folderChildIdx = new String[2];

		folderChildIdx[0] = String.valueOf(TAB_IDX_DTL);
		folderChildIdx[1] = String.valueOf(TAB_IDX_DTL);

		return folderChildIdx;
	}

	protected SimpleBasePk getPk(ActionForm formIn, HttpServletRequest request) {

		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		CatalogOptionHdrPk pk = null;
		HttpSession session = request.getSession(false);

		//TODO: Add the following line to ProjectSecurityConstants.java
		//public static final String SP_SHARE_CATALOG_OPTION = "SP_SHARE_CATALOG_OPTION";
		String companyCode = WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_CATALOG_OPTION);

//		edit the following with appropriate form field names
		pk = new CatalogOptionHdrPk(companyCode, form.getRefMasterCode());
		return pk;
	}

	protected void setFormType(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
		HttpServletResponse response, ActionErrors errors){

		CatalogOptionMaintenanceForm form = (CatalogOptionMaintenanceForm) formIn;
		form.setFormType(ProjectConstants.FORM_TYPE_MAINT);
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////
}
